package cn.doctor.assistant.pad.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import cn.doctor.assistant.pad.ui.UI;

/**
 * Created by jiaolf on 2016/3/21.
 */
public class BaseFragment extends Fragment {

    protected BaseActivity activity;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        Log.d("jzsn", "onCreate --- "+this.getClass().getName());
        super.onCreate(savedInstanceState);
        activity = (BaseActivity) getActivity();
    }

    // Fragment重新显示的回调
    public void onRedisplay() {
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        Log.d("jzsn", "onCreateView --- " + this.getClass().getName());
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    public void showDialogMessage(String paramString) {
        activity.showDialogMessage(paramString);
    }

    public void showDialogMessage(String title, String msg) {
        activity.showDialogMessage(title, msg);
    }

    protected void showDialogMessage(String title, String message, boolean cancelable, final Runnable callback) {
        activity.showDialogMessage(title, message, cancelable, callback);
    }

    protected void showProgress(final String msg) {
        activity.showProgress(msg);
    }

    protected void showProgress(final String msg, final boolean cancelable) {
        activity.showProgress(msg, cancelable);
    }

    protected void showToast(String paramString) {
        UI.showToast(paramString);
    }

    protected void stopProgress() {
        activity.stopProgress();
    }
}
